using UnityEngine;

namespace ProceduralPrimitivesUtil
{
	public class Arrow : PPBase
	{
		[Header("Basic parameters")]
		public float width1 = 0.5f;

		public float width2 = 0.3f;

		public float width3 = 1f;

		public float length1 = 1f;

		public float length2 = 0.5f;

		public float height = 0.5f;

		[Header("Segments")]
		public int widthSegs1 = 2;

		public int lengthSegs1 = 2;

		public int widthSegs2 = 4;

		public int lengthSegs2 = 2;

		public int heightSegs = 2;

		[Header("Mapping Coordinates")]
		public bool generateMappingCoords = true;

		public bool realWorldMapSize;

		public Vector2 UVOffset = new Vector2(0f, 0f);

		public Vector2 UVTiling = new Vector2(1f, 1f);

		[Header("Others")]
		public bool flipNormals;

		protected override void CreateMesh()
		{
			m_mesh.name = "Arrow";
			width1 = Mathf.Clamp(width1, 1E-05f, 10000f);
			width2 = Mathf.Clamp(width2, 1E-05f, 10000f);
			width3 = Mathf.Clamp(width3, width2, 10000f);
			length1 = Mathf.Clamp(length1, 1E-05f, 10000f);
			length2 = Mathf.Clamp(length2, 1E-05f, 10000f);
			height = Mathf.Clamp(height, 1E-05f, 10000f);
			lengthSegs1 = Mathf.Clamp(lengthSegs1, 1, 100);
			widthSegs1 = Mathf.Clamp(widthSegs1, 1, 100);
			lengthSegs2 = Mathf.Clamp(lengthSegs2, 1, 100);
			widthSegs2 = Mathf.Clamp(widthSegs2, 1, 100);
			heightSegs = Mathf.Clamp(heightSegs, 1, 100);
			float num = width1 * 0.5f;
			float num2 = width2 * 0.5f;
			float num3 = width3 * 0.5f;
			float num4 = height * 0.5f;
			float num5 = length1 * 0.5f;
			float num6 = length2 * 0.5f;
			Vector3 vector = new Vector3(0f - num3, 0f, num5 - num6);
			Vector3 vector2 = new Vector3(0f, 0f, num5 + num6);
			Vector3 vector3 = new Vector3(num3, 0f, num5 - num6);
			Vector3 vector4 = vector - vector2;
			Vector3 vector5 = vector2 - vector3;
			CreateTriangle(pivotOffset + m_rotation * new Vector3(0f, num4, num5), m_rotation * Vector3.forward, m_rotation * Vector3.right, width3, length2, 0f, widthSegs2, lengthSegs2, generateMappingCoords, realWorldMapSize, UVOffset, UVTiling, flipNormals);
			CreateTriangle(pivotOffset + m_rotation * new Vector3(0f, 0f - num4, num5), m_rotation * Vector3.forward, m_rotation * Vector3.right, width3, length2, 0f, widthSegs2, lengthSegs2, generateMappingCoords, realWorldMapSize, UVOffset, UVTiling, !flipNormals);
			CreatePlane(pivotOffset + m_rotation * new Vector3(0f, 0f, num5 - num6), m_rotation * Vector3.up, m_rotation * Vector3.right, width3, height, widthSegs2, heightSegs, generateMappingCoords, realWorldMapSize, UVOffset, UVTiling, flipNormals);
			CreatePlane(pivotOffset + m_rotation * (vector + vector2) * 0.5f, m_rotation * Vector3.up, m_rotation * vector4.normalized, vector4.magnitude, height, lengthSegs2, heightSegs, generateMappingCoords, realWorldMapSize, UVOffset, UVTiling, flipNormals);
			CreatePlane(pivotOffset + m_rotation * (vector2 + vector3) * 0.5f, m_rotation * Vector3.up, m_rotation * vector5.normalized, vector5.magnitude, height, lengthSegs2, heightSegs, generateMappingCoords, realWorldMapSize, UVOffset, UVTiling, flipNormals);
			Vector3 vector6 = new Vector3(0f - num, 0f, 0f - num6 - num5);
			Vector3 vector7 = new Vector3(0f - num2, 0f, 0f - num6 + num5);
			Vector3 vector8 = new Vector3(num2, 0f, 0f - num6 + num5);
			Vector3 vector9 = new Vector3(num, 0f, 0f - num6 - num5);
			Vector3 vector10 = vector6 - vector7;
			Vector3 vector11 = vector8 - vector9;
			CreateTrapezoid(pivotOffset + m_rotation * new Vector3(0f, num4, 0f - num6), m_rotation * Vector3.forward, m_rotation * Vector3.right, width1, width2, length1, 0f, widthSegs1, lengthSegs1, generateMappingCoords, realWorldMapSize, UVOffset, UVTiling, flipNormals);
			CreateTrapezoid(pivotOffset + m_rotation * new Vector3(0f, 0f - num4, 0f - num6), m_rotation * Vector3.forward, m_rotation * Vector3.right, width1, width2, length1, 0f, widthSegs1, lengthSegs1, generateMappingCoords, realWorldMapSize, UVOffset, UVTiling, !flipNormals);
			CreatePlane(pivotOffset + m_rotation * new Vector3(0f, 0f, 0f - num6 - num5), m_rotation * Vector3.up, m_rotation * Vector3.right, width1, height, widthSegs1, heightSegs, generateMappingCoords, realWorldMapSize, UVOffset, UVTiling, flipNormals);
			CreatePlane(pivotOffset + m_rotation * (vector6 + vector7) * 0.5f, m_rotation * Vector3.up, m_rotation * vector10.normalized, vector10.magnitude, height, lengthSegs1, heightSegs, generateMappingCoords, realWorldMapSize, UVOffset, UVTiling, flipNormals);
			CreatePlane(pivotOffset + m_rotation * (vector8 + vector9) * 0.5f, m_rotation * Vector3.up, m_rotation * vector11.normalized, vector11.magnitude, height, lengthSegs1, heightSegs, generateMappingCoords, realWorldMapSize, UVOffset, UVTiling, flipNormals);
		}
	}
}
